package com.itheima.health.controller;

import com.itheima.health.common.MessageConst;
import com.itheima.health.entity.Result;
import com.itheima.health.pojo.Setmeal;
import com.itheima.health.service.MobileSetMealService;
import com.itheima.health.service.SetMealService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author ：wm
 * @date ：Created in 2022年06月08日
 * @description ：
 * @version: 1.0
 */
@Slf4j
@RestController
@RequestMapping("/mobile/setmeal")
public class MobileSetMealController {

    @Autowired
    private MobileSetMealService mobileSetMealService;

    @Autowired
    private SetMealService setMealService;

    @GetMapping("/getSetmeal")
    public Result getSetmeal(){

        List<Setmeal> setmeal = mobileSetMealService.getSetmeal();


        return new Result(true, MessageConst.QUERY_ORDER_SUCCESS,setmeal);
    }

    //根据id查询套餐
    @GetMapping("/findById")
    public Result findById(Integer id){
        log.info("[根据id查询套餐]");
        log.info("id:"+id);

        //根据id查询套餐
        Setmeal setmeal = setMealService.findById(id);

        log.info(setmeal.toString());
        return new Result(true,MessageConst.QUERY_SETMEALLIST_SUCCESS,setmeal);
    }
}
